import { _decorator, Component, Node, Collider } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('AirWallCollisionEvent')
export class AirWallCollisionEvent extends Component {
    start() {
        let collider = this.node.getComponent(Collider);
        // 监听触发事件
        collider.on('onCollisionEnter', this.onCollisionEnter, this);
        collider.on('onCollisionStay', this.onCollisionStay, this);
        collider.on('onCollisionExit', this.onCollisionExit, this);
    }

    update(deltaTime: number) {

    }

    onCollisionEnter(e) {
        // console.log('onCollisionEnter', e);
    }

    onCollisionStay(e) {
        // console.log('onCollisionStay', e);
        if (e.otherCollider.node.name == 'player') {
            this.node.children[0].active = true
            this.node.children[1].active = true
        }
    }

    onCollisionExit(e) {
        // console.log('onCollisionExit', e);
        if (e.otherCollider.node.name == 'player') {
            this.node.children[0].active = false
            this.node.children[1].active = false
        }
    }
}


